<%@include file="/page/tag.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<!--框架必需start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/jquery.js"></script>
<script type="text/javascript" src="${ctp}/js/qui/language/cn.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/framework.js"></script>
<link href="${ctp}/QUI/libs/css/import_basic.css" rel="stylesheet"	type="text/css" />
<link href="${ctp}/QUI/libs/skins/lightBlue/style.css" rel="stylesheet" type="text/css" id="theme" themeColor="deepBlue"/>

<!-- 表单验证start -->
<script src="${ctp}/QUI/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="${ctp}/QUI/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->

<!-- 树组件start -->
<script type="text/javascript" src="${ctp}/js/qui/ztree.js"></script>
<link type="text/css" rel="stylesheet" href="${ctp}/css/ztree.css"></link>
<!-- 树组件end -->

<!-- 树形下拉框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/selectTree.js"></script>
<!-- 树形下拉框end -->

<!-- 日期选择框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->

<!-- 树形双选器start -->
<%-- <script type="text/javascript" src="${ctp}/QUI/libs/js/form/listerTree.js"></script> --%>
<script type="text/javascript" src="${ctp}/js/qui/listerTree.js"></script>
<!-- 树形双选器end -->


<!--框架必需end-->

<style>
.model_block_div {
vertical-align:top;
	display: inline-block;
	margin-right:18px;
}

.del_f{
	margin-left: 10px;
}
tr{    height: 16px;}
</style>
</head>
<body>

	<form id="ff" target="frmright" class="" method="post" action="" failAlert="验证未通过">
		<input type="hidden"  name="sysUserInfoId"  value="<c:out value="${sysUserInfo.sysUserInfoId }"/>"/>
		<table class="tableStyle" formMode="line">
			
			<tr>
				<td>账号：</td>
				<td colspan="">
					<input type="text"  name="userAccount" style="width: 90%;" class="validate[required]"  value="<c:out value="${sysUserInfo.userAccount }"/>"/>
				</td>
			
				<td>名称：</td>
				<td colspan="">
					<input type="text"  name="userName" style="width: 90%;" class="validate[required]"  value="<c:out value="${sysUserInfo.userName }"/>"/>
				</td>
				
				<td>工号：</td>
				<td colspan="">
					<input type="text"  name="userCode" style="width: 90%;" class=""  value="<c:out value="${sysUserInfo.userCode }"/>"/>
				</td>
				
			</tr>
			
			<tr>
				<td>手机号码：</td>
				<td colspan="">
					<input type="text"  name="userPhone" style="width: 90%;" class=""  value="<c:out value="${sysUserInfo.userPhone }"/>"/>
				</td>
				
				<td>固话：</td>
				<td colspan="">
					<input type="text"  name="userTelephone" style="width: 90%;" class=""  value="<c:out value="${sysUserInfo.userTelephone }"/>"/>
				</td>
				
				<td>传真：</td>
				<td colspan="">
					<input type="text"  name="userFax" style="width: 90%;" class=""  value="<c:out value="${sysUserInfo.userFax }"/>"/>
				</td>
			</tr>
			
			<tr>
				
				<td>部门：</td>
				<td colspan="3">
					<c:choose>
						<c:when test="${!empty  sysUserInfo}">
							
							<div class="selectTree validate[required]" name="sysDept.sysDeptId" selectedValue="<c:out value="${sysUserInfo.sysDept.sysDeptId}"/>" url="${ctp}/sysDept/userCompanyDeptTree_<c:out value="${sysUserInfo.sysCompanyInfo.sysCompanyInfoId}"/>.do" id="selectTree1"></div>

						</c:when>
						<c:otherwise>
							<c:out value="${param.deptName }"/>
							<input type="hidden"  name="sysDept.sysDeptId" value="<c:out value="${param.deptId }"/>"/>
						</c:otherwise>
					</c:choose>
					
					<c:if test="${sessionScope.userInfo.userType == UserType.MASTER_key }">
						<input type="hidden"  name="sysCompanyInfo.sysCompanyInfoId" value="<c:out value="${param.companyId }"/>"/>
					</c:if>
					
				</td>
				
				<td colspan="2" >
					<c:if test="${empty  sysUserInfo}">
						<div style="color: red; text-align: left; margin-left: 12px;">*默认密码为：<c:out value="${baseElementCode.INIT_PWD }"/></div>
					</c:if>
				</td>
				
				<%-- <td colspan=""> 排序：</td>
				<td>
					 <input type="text"  name="sortIndex" style="width: 50%;" class="validate[required]"  value="<c:out value="${sysUserInfo.sortIndex }"/>"/>
				</td> --%>
				
			</tr>
			
			<tr>
				<td>地址：</td>
				<td colspan="5">
					<input type="text" name="userAddr" style="width: 90%;" class="" value="<c:out value="${sysUserInfo.userAddr }"/>"/>
				</td>
			</tr>
			
			<tr>
				<td>邮件地址：</td>
				<td colspan="">
					<input type="text"  name="userEmail" style="width: 90%;" class=""  value="<c:out value="${sysUserInfo.userEmail }"/>"/>
				</td>
			
				<td>性别：</td>
				<td colspan="">
					<c:choose>
						<c:when test="${sysUserInfo.userSex == '女' }">
							<input name="userSex" id="sex_male" type="radio" value="男"/><label for="sex_male" class="hand">男</label>
							<input name="userSex" id="sex_female" type="radio" value="女" checked="checked"/><label for="sex_female" class="hand">女</label>
						</c:when>
						<c:otherwise>
							<input name="userSex" id="sex_male" type="radio" value="男"  checked="checked"/><label for="sex_male" class="hand">男</label>
							<input name="userSex" id="sex_female" type="radio" value="女"/><label for="sex_female" class="hand">女</label>
						</c:otherwise>
					</c:choose>
					
				</td>
				
				<td>排序：</td>
				<td colspan="">
					<input type="text"  name="sortIndex" style="width: 90%;" class="validate[custom[onlyNumber]]"  value="<c:out value="${sysUserInfo.sortIndex }" default="0"/>"/>
				</td>
				
				<%-- <td colspan=""> 排序：</td>
				<td>
					 <input type="text"  name="sortIndex" style="width: 50%;" class="validate[required]"  value="<c:out value="${sysUserInfo.sortIndex }"/>"/>
				</td> --%>
				
			</tr>
			
			<tr>
				<td colspan="6">
					<input id="h_model" type="hidden" value="<c:out value="${sysUserInfo.sysModelIds }"/>"/>
					<div id="modelListDiv" class="ali01">
					</div>
				</td>
			</tr>
			
			<tr>
				<td colspan="6">
					<input type="button" value="提交" onclick="submitF()" />
				 	<input type="reset" value="取消" onclick="closeWin()" />
				 </td>
			</tr>
		</table>
	</form>
	<script>
		function closeWin() {
			top.Dialog.close();
		}

		function submitF() {
			  if($("#ff").validationEngine({returnIsValid: true})){
			 	$.ajax({
					url : "${ctp}/sysUserInfo/sysUserInfo_edit.do",
					type : "post",
					data : $("#ff").serialize(),
					success : function(data) {
						var popBox = new top.Dialog({
							Width:300,
	       					Height:110
						});
						if (data.result) {
							popBox.Title = data.msg;
							popBox.InnerHtml = '<table height="100%" border="0" align="center" cellpadding="10" cellspacing="0">\
										<tr><td align="right"><input type="button" id="Icon_' + this.ID + '" class="icon_alert" align="absmiddle"></td>\
											<td align="left" id="Message_' + this.ID + '" style="font-size:' + (popBox.defaultFontSize) + 'px;font-family:' + (popBox.defaultFontFamily) + '">' + data.msg + '</td></tr>\
									</table>';
							popBox.ShowCloseButton = false;
							popBox.ShowCancelButton = false;
							
							popBox.OKEvent = function() {
								popBox.close();
								top.frmright.reflushList();
								top.Dialog.close();
							};
							popBox.show();
							popBox.okButton.parentNode.style.textAlign = "center";
						} else {
							top.Dialog.alert(data.msg, null, null, null, 2);
						};
					}
				});
			 };
		}
		
$(function(){
			
			//获取模块
			$.ajax({
				url:"${ctp}/sysModel/sys_company_model_list_all.do",
				success:function(data){
					var list = data, ziArr = new Array();
					
					for(var i in list){
						if(list[i].sysModel == null){
							$("#modelListDiv").append('<div class="model_block_div"><ul id="mb_'+list[i].sysModelId+'" class="model_block " ><input id="modelInput_'+list[i].sysModelId+'" class="model_block_input mbi_'+list[i].sysModelId+'" type="checkbox" name="sysModelIds" value="'+list[i].sysModelId+'"/><label for="modelInput_'+list[i].sysModelId+'" class="hand" ><b style="    font-size: 14px;">'+list[i].modelName+'</b></label></ul><div>');
						} else{
							ziArr.push(list[i]);
						}
					}
					
					for(var i in ziArr){
						$("#mb_"+ziArr[i].sysModel.sysModelId).append('<li class="model_block_zi"><input id="modelInput_'+ziArr[i].sysModelId+'" type="checkbox" class="model_block_zi_input model_block_'+ziArr[i].sysModel.sysModelId+'" parentId="'+ziArr[i].sysModel.sysModelId+'" name="sysModelIds" value="'+ziArr[i].sysModelId+'"/><label for="modelInput_'+ziArr[i].sysModelId+'" class="hand">'+ziArr[i].modelName+'</label></li>');
					}
					var initModel = "${sysUserInfo.sysModelIds}";
					var initModelArr = initModel.split(",");
					for(var i in initModelArr){
						$("#modelInput_"+initModelArr[i]).attr('checked',true);
					}
					
				}
			});
			
			
			$(document).on("click",".model_block_zi_input", function(){
				var parentId = $(this).attr("parentId");
				$(".mbi_"+parentId).attr('checked',true);
			});
			
			$(document).on("click",".model_block_input", function(){
				var flag = $(this).is(':checked');
				var id = $(this).val();
				if(flag){
					$(".model_block_"+id).attr('checked',true);
				} else{
					$(".model_block_"+id).attr('checked',false);
				}
			});
			
		})
	</script>
</body>
</html>

